<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head>
    <title>待审核</title>
    <c:import url="../../header.jsp"/>
    <link rel="stylesheet" href="${rootUrl}/static/css/time-status-color.css?v=${version}">
    <link rel="stylesheet" type="text/css" href="${basePath}/static/css/production.css?v1"/>
    <style>
        table.crm-table.cell-border tbody td{
            white-space: nowrap;
        }
    </style>
</head>
<body>
<div class="body-main">
    <input type="hidden" id="auditStatusArr" name="auditStatusArr" value="${status}">
    <div class="titleSearch">
        <div class="layui-inline">
            <div class="layui-inline">
                <label style="margin-left: 8px;"></label>业务类型：</label>
                <div class="layui-input-inline">
                    <div id="business_typeCode" style="width:264px;">
                        <input type="hidden" name="typeCodeId" class="plug-in-msg"/>
                        <input type="hidden" name="typeCode" id="typeCode" class="plug-in-code"/>
                        <input type="text" readonly placeholder="请选择业态" class="chose-plugIn layui-input"
                               name="businessName">
                        <div class="bus-picker">
                            <div class="bus-picker-tab">
                                <a href="javascript:void(0);" class="active">请选择业态</a>
                            </div>
                            <div class="bus-picker-content"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-inline" style="margin-left: 25px">
            <label>退单申请人：</label>
            <div class="layui-input-inline select2-inline">
                <select class="select-style" name="abandonUserId" id="abandonUserId" divisionUser-select-law>
                    <option value>请选择</option>
                </select>
            </div>
        </div>
        <div class="layui-inline" style="margin-left: 10px">
            <label>审核人：</label>
            <div class="layui-input-inline select2-inline">
                <select class="select-style" id="auditorId" name="auditorId" auditorUser-select-law>
                    <option value>请选择</option>
                </select>
            </div>
        </div>

        <div class="layui-inline" style="margin-left: 10px">
            <label>客户电话：</label>
            <div class="layui-input-inline">
                <input type="text" class="input-style" placeholder="电话号码" id="customerPhone" name="customerPhone">
            </div>
        </div>
        <div class="form-label">
            <label>申请理由：</label>
        </div>
        <div class="layui-inline">
            <select class="select-style " name="abandonReason" id="abandonReason">
                <option value>请选择</option>
                <c:forEach var="abolish" items="${list}">
                    <option value="${abolish.code}">${abolish.name}</option>
                </c:forEach>
            </select>
        </div>
        <br>
        <div class="layui-inline">
            <label>申请时间：</label>
            <div class="layui-inline">
                <input type="text" name="abandonReasonTimeStart" placeholder="开始时间" class="Wdate input-style"
                       id="d4311"
                       onFocus="var d4312=$dp.$('d4312'); WdatePicker({onpicked:function(){d4312.focus();}, maxDate:'#F{ $dp.$D(\'d4312\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
            <span>~</span>
            <div class="layui-inline">
                <input type="text" name="abandonReasonTimeEnd" placeholder="结束时间" class="Wdate input-style"
                       id="d4312"
                       onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}', dateFmt:'yyyy-MM-dd'})">
            </div>
        </div>
        <div class="layui-inline" style="margin-left: 22px">
            <label>关键字：</label>
            <div class="layui-input-inline">
                <input type="text" class="input-style" style="width: 200px;" placeholder="客户名称/生产订单编号/订单编号/企业名称"
                       maxlength="50"
                       id="keyWords"
                       name="keyWords">
            </div>
        </div>
        <div class="layui-inline">
            <button class="layui-btn layui-btn-mini layui-btn-normal" onclick="dataTableReload()">搜索</button>
            <button class="layui-btn layui-btn-mini layui-btn-primary" onclick="cleanSearch()">清空</button>
        </div>
    </div>
    <div class="table-conter">
        <d:hasUrlAuth authCode="ZZSC_AUDIT">
        <a href="javascript:void(0)" onclick="auditOrder('auditTable','')"
           class="layui-btn layui-btn-mini" btnauthCode="ZZSC_AUDIT">审核</a>
        </d:hasUrlAuth>
        <d:hasUrlAuth authCode="ZZSC_UPDATE_AUDIT_USER">
        <a href="javascript:void(0)" onclick="updateFlowUser('auditTable','')"
           class="layui-btn layui-btn-mini" btnauthCode="ZZSC_UPDATE_AUDIT_USER">变更审核人</a>
        </d:hasUrlAuth>
        <d:hasUrlAuth authCode="ZZSC_TO_TITHDRAW">
        <a href="javascript:void(0)" onclick="toTithdraw('auditTable','')"
           class="layui-btn layui-btn-mini" btnauthCode="ZZSC_TO_TITHDRAW">撤回</a>
        </d:hasUrlAuth>
            <div class="fr other-span">
             <div class="fr">
                 <span class="bgBlueGreen">合同超期</span>
                 <span class="bgRed">订单超期</span>
                 <span class="bgBlue">节点超期</span>
             </div>
            </div>
        <div class="dataTables_wrapper no-footer">
            <!--表格 end-->
            <table class="cell-border crm-table columnsHidden dataTable" id="auditTable">
                <thead>
                <tr>
                    <th width="20"><input type="checkbox" class="checkall"/></th>
                    <th width="60">序号</th>
                    <th width="60">订单来源</th>
                    <th width="100">生产订单编号</th>
                    <th width="100">订单编号</th>
                    <th width="130">客户</th>
                    <th width="80">当前完成节点</th>
                    <th width="80">业务类型</th>
                    <th width="80">订单产品</th>
                    <th width="80">销售订单备注</th>
                    <th width="80">申请原因</th>
                    <th width="130">申请时间</th>
                    <th width="130">申请人</th>
                    <th width="130">当前审核人</th>
                    <th width="150">签单时间</th>
                    <th width="70">签单商务</th>
                    <th width="150">签单部门</th>
                    <th width="150">最新备注</th>
                    <th width="150">流程人员</th>
                    <th width="150">流程部门</th>
                    <th width="150">企业名称</th>
                    <th width="150">操作</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
</div>


</div>
<c:import url="/WEB-INF/jsp/footer.jsp"/>
<script type="text/javascript"
        src="${basePath}/static/js/zzsc/production/sc_business.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/zzsc/production/sc_common.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/zzsc/production/sc_auditorUser.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/zzsc/production/sc_divisionUser.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/zzsc/inprocess/inprocess_list.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/choose.extend.js?v=${version}"></script>
<script type="text/javascript"
        src="${basePath}/static/js/main-tabs.js?v=${version}"></script>
<script src="${basePath}/static/js/zzsc/common/functionalTool.js?v=${version}"></script>
<script type="text/javascript" src="${basePath}/static/js/zzsc/common/call_common.js?v=${version}"></script>
<script type="text/javascript">
    Plug.plug_in("post", "${basePath}/zzsc/common/tree_book_list.do?code=BUS_YT_ZZ&&type=2&&level=2", "#business_typeCode", '选择业态', '', true, 'BUS_YT_ZZ', '', '');
</script>
<script type="text/javascript" charset="utf-8">
    var table;
    $(document).ready(function () {
        //初始化dataTable列表
        table = $('#auditTable').dataTableExtend({
            "ajax": {"url": "${basePath}/zzsc/audit/query_audit_list.do", "type": "post"},
            "fnServerParams": function (aoData) {
                paras = $('.titleSearch').serializeJson();
                aoData = $.extend(aoData, paras);
                return aoData;
            },
            "scrollX": "true",//是否开启横项滚动
            "fixedColumns": {//锁定列，只有开启scrollX时才生效
                "leftColumns": 4,//左侧锁定2列
                "rightColumns": 1//右侧锁定1列
            },
            "aoColumns": [
                {
                    "orderable": false,
                    "data": "id",
                    "render": function (data, type, full, meta) {
                        return '<input type="checkbox"  name="ids" class="checkchild"  value="' + data + '" />';
                    }
                }
                , {
                    "orderable": false,
                    "render": function (data, type, full, meta) {
                        return meta.row + 1;
                    }
                }, {
                    "title": "订单来源",
                    "orderable": false,
                    "data": "signOrgName"
                }, {
                    "orderable": false,
                    "data": "scProductOrderNo",
                    "render": function (data, type, row) {
                        {
                            return '<a href="javascript:;"  class="layui-table-link" onclick="openOrderInfoDetail(\'' + row.scProductOrderNo + '\',\'' + row.id + '\')" /><p>' + data + '</p></a>';
                        }
                    }
                }, {
                    "orderable": false,
                    "data": "orderNo",
                    "render": function (data, type, full, meta) {
                        return ('<a href=\'javascript:void(0)\' ti  onclick="openBusinessDetail(\'' + full.orderNo + '\',\'' + full.orderId + '\')" /><span class="layui-table-link">' + data + '</span></a>&nbsp;');
                    }
                }, {
                    "orderable": false,
                    "data": "customerName",
                    "render": function (d, type, r) {
                        return emptyStringConvert(d) + '<p>' + emptyStringConvert(r.customerPhone) + '</p>';
                    }
                }, {
                    "title": "当前已完成节点",
                    "orderable": false,
                    "data": "latestEndNodeName"
                }, {
                    "title": "业务类型",
                    "orderable": false,
                    "data": "businessProductName"
                },
                {
                    "title": "产品类型",
                    "orderable": false,
                    "data": "productName"
                },
                {
                    "title": "销售订单备注",
                    "orderable": false,
                    "data": "orderRemark",
                    "render": function (data, type, full, meta) {
                        if(data){
                            return  '<div class="line2" style="min-width: 120px" title="'+data+'">'+data+'</div> ';
                        }else{
                            return '';
                        }
                    }
                },
                {
                    "title": "申请原因",
                    "orderable": false,
                    "data": "abandonReason"

                }, {
                    "title": "申请时间",
                    "orderable": true,
                    "data": "abandonReasonTime"

                }, {
                    "title": "申请人",
                    "orderable": false,
                    "data": "abandonUser"

                }, {
                    "title": "当前审核人",
                    "orderable": false,
                    "data": "auditorName"

                }, {
                    "title": "签单时间",
                    "orderable": true,
                    "data": "receiveOrderDate"
                }, {
                    "title": "签单商务",
                    "orderable": false,
                    "data": "signUserName"
                },
                { //签单部门
                    "orderable": false,
                    "data": "signUserOrgName"
                },{//最新备注时间
                    "orderable": true,
                    "data": "lastRemarkTime",
                    "render": function (d, type, r) {
                        (d==null)&&(d='');
                        (r.lastRemark==null)&&(r.lastRemark='');
                        (r.lastUser==null)&&(r.lastUser='');
                        return '<div class="line2" style="min-width: 120px" title="'+r.lastRemark+'">'+r.lastRemark+'</div> '
                            + '<p>' + r.lastUser + '</p>'+ '<p>' + d + '</p>';
                    }
                },
                { //流程人员
                    "orderable": false,
                    "data": "flowUserName"
                },
                { //流程部门
                    "orderable": false,
                    "data": "flowUserOrgName"
                },{
                    "orderable": false,
                    "data": "companyName",
                    "render": function (data, type, full, meta) {
                        (data==null)&&(data='');
                        return '<div class="line2" style="min-width: 50px" title="'+data+'">'+data+'</div> ';
                    }
                },
                {
                    "orderable": false,
                    "data": "id",
                    "render": function (d, type, r, meta) {
                        var result = "";
                        result += '<a href=\'javascript:void(0)\' ti  onclick="callPhoneByProduction(\'' + r.id + '\')" /><span style="color: #0066ff; font-weight: bold ">打电话</a>&nbsp;&nbsp;&nbsp;';
                        <d:hasUrlAuth authCode="ZZSC_AUDIT">
                        result += '<a href=\'javascript:void(0)\' onclick="auditOrder(\'' + "" + '\',\'' + r.id + '\')" /><span style="color: #0066ff; font-weight: bold ">审核</a>&nbsp;';//审核
                        </d:hasUrlAuth>
                        <d:hasUrlAuth authCode="ZZSC_TO_TITHDRAW">
                        result += '<a href=\'javascript:void(0)\' onclick="toTithdraw(\'' + "" + '\',\'' + r.id + '\')" /><span style="color: #0066ff ">撤回</a>&nbsp;';//撤回
                        </d:hasUrlAuth>
                        result += '<a href=\'javascript:void(0)\' ti  onclick="remarkLayer(\'' + r.id + '\' )" /><span style="color: #0066ff ">备注</a>';//备注
                        return result;
                    }
                }], "columnDefs": [{
                targets: [2], //第1，2，3列
                createdCell: function (td, cellData, rowData, row, col) {
                    var nodestatus = rowData.nodeTimeStatus;
                    var orderstatus = rowData.orderTimeStatus;
                    if ("OVERDUE_STATE2" == rowData.contractTimeStatus) {
                        $(td).parent().addClass("bgBlueGreen");
                        return;
                    }
                    if ("OVERDUE_STATE2" == orderstatus) {
                        $(td).parent().addClass("bgRed");
                        return;
                    }
                    if ("OVERDUE_STATE2" == nodestatus) {
                        $(td).parent().addClass("bgBlue");
                        return;
                    }
                }
            }, {
                targets: ["_all"], "defaultContent": ""
            }]
        });

        $('.title-tab').on('click', 'a', null, function () {
            var $this = $(this);
            var status = $this.attr('data-status');
            var href = window.location.href;
            if (href.indexOf('status=') > -1) {
                href = href.substring(0, href.indexOf('status=') - 1);
            }
            window.location.href = href + (href.indexOf('?') > -1 ? '&' : '?') + 'status=' + status;
        });
    });

    function export_data() {
        export_table('/zzsc/audit/export.do', getSearchData());
    }

    //撤回
    function toTithdraw(tableid, id) {
        // debugger;
        if (null != tableid && "" != tableid) {
            var id = scCommonGetCheckedallproorder(tableid);
            if (id.length > 1) {
                DGG.Warning('只能选择一个订单！');
                return;
            }
            if (id.length == 0) {
                DGG.Warning('请选择一个订单！');
                return;
            }
            DGG.Confire("是否确认撤回选中的生产单？", '', function () {
                DGG.loading();
                $.ajax({
                    url: sysInfo.basePath + '/zzsc/audit/to_tithdraw_order.do?id=' + id,
                    type: "POST",
                    dataType: "json",
                    success: function (obj) {
                        if (obj.code != 0) {
                            DGG.Errors(obj.msg);
                        } else {
                            DGG.Succeed('操作成功！');
                            window.location.reload();
                        }
                    }
                });
            }, function () {

            });
        } else {
            DGG.Confire("是否确认撤回选中的生产单？", '', function () {
                DGG.loading();
                $.ajax({
                    url: sysInfo.basePath + '/zzsc/audit/to_tithdraw_order.do?id=' + id,
                    type: "POST",
                    dataType: "json",
                    success: function (obj) {
                        if (obj.code != 0) {
                            DGG.Errors(obj.msg);
                        } else {
                            DGG.Succeed('操作成功！');
                            window.location.reload();
                        }
                    }
                });
            }, function () {

            });
        }
    }

    function dataTableReload() {
        $('#auditTable').dataTableExtend("reload");
    }
</script>
</div>
</body>
</html>
